Skip to content

Python: Port UnreachableCode.ql#21597

Open
tausbn wants to merge 1 commit intomainfrom
tausbn/python-port-unreachable-code
Open

Python: Port UnreachableCode.ql#21597
tausbn wants to merge 1 commit intomainfrom
tausbn/python-port-unreachable-code

Conversation

@tausbn
Copy link
Copy Markdown
Contributor

@tausbn tausbn commented Mar 27, 2026

A simple use of API graphs instead of points-to.

@tausbn tausbn added the no-change-note-required This PR does not need a change note label Apr 7, 2026
@tausbn
Copy link
Copy Markdown
Contributor Author

tausbn commented Apr 7, 2026

DCA looks good. Four false positives removed -- no other changes.

@tausbn tausbn marked this pull request as ready for review April 7, 2026 21:22
@tausbn tausbn requested a review from a team as a code owner April 7, 2026 21:22
Copilot AI review requested due to automatic review settings April 7, 2026 21:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the Python UnreachableCode.ql query to use API graphs for recognizing contextlib.suppress usage, replacing the previous LegacyPointsTo-based resolution approach.

Changes:

  • Replace LegacyPointsTo import with semmle.python.ApiGraphs.
  • Update suppression_in_scope to match with contextlib.suppress(...) using an API-graph-based call pattern.
Show a summary per file
File Description
python/ql/src/Statements/UnreachableCode.ql Switches contextlib.suppress detection from points-to resolution to API graph matching.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@tausbn
Copy link
Copy Markdown
Contributor Author

tausbn commented Apr 8, 2026

DCA performance results seem to indicate a 10% slowdown for FreeCAD, but I've been unable to verify this locally. I think workflow failures is causing the reported data to be somewhat confused. (In my local testing, the query -- when run on FreeCAD -- takes only ~20s. Much faster than the original points-to based query.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants